<template>
    <button @click="callTest2">在父级调用子级的方法</button>
    <div style="display: flex">
        <div class="child">
            <test1 />
        </div>
        <div class="child">
            <test2 ref="t2" />
        </div>
    </div>
    <router-view />
</template>
<script>
import Test1 from "./Test1.vue";
import Test2 from "./Test2.vue";
export default {
    components: {Test2, Test1},
    methods:{
        callTest2(){
            // 调用test2里面的方法
            // 获取到t2
            const t2 = this.$refs.t2
            t2.changeAAA() // 直接调用子组件的方法
        }
    }
}
</script>
<style>
.child{
    flex: 1;
    border: solid 3px #000;
    margin: 10px;
    min-height: 20px;
}
</style>